package com.getpebble.android.framework.protocol.outbound;

import com.getpebble.android.framework.protocol.EndpointId;

public class PblOutboundSystemMessage extends PblOutboundMessage {
    private SysMsgCommand mSysMsgCommand;

    public enum SysMsgCommand {
        FIRMWARE_AVAILABLE((byte) 0),
        FIRMWARE_START((byte) 1),
        FIRMWARE_COMPLETE((byte) 2),
        FIRMWARE_FAIL((byte) 3),
        FIRMWARE_UP_TO_DATE((byte) 4),
        FIRMWARE_OUT_OF_DATE((byte) 5),
        FIRMWARE_START_RESPONSE((byte) 10),
        FIRMWARE_UNKNOWN((byte) -1);
        
        private byte command;

        private SysMsgCommand(byte command) {
            this.command = command;
        }

        public byte getCommand() {
            return this.command;
        }
    }

    public PblOutboundSystemMessage(SysMsgCommand sysMsgCommand) {
        super(EndpointId.SYSTEM_MESSAGE);
        this.mSysMsgCommand = sysMsgCommand;
    }

    public synchronized byte[] getBytes() {
        if (!areBytesCached()) {
            addBytes(Byte.valueOf((byte) 0));
            addBytes(Byte.valueOf(this.mSysMsgCommand.getCommand()));
        }
        return super.getBytes();
    }
}
